﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Power.DBUtility;//Please add references
namespace Power.DAL
{
	/// <summary>
	/// 数据访问类:Meter_h_dataDAO
	/// </summary>
	public partial class Meter_h_dataDAO
	{
		public Meter_h_dataDAO()
		{}
		#region  BasicMethod

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperSQL.GetMaxID("id", "meter_h_data"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int id)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from meter_h_data");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
			};
			parameters[0].Value = id;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(Power.Model.Meter_h_data model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into meter_h_data(");
			strSql.Append("station_id,meter_id,evt_time,v_a,v_b,v_c,v_avg,u_ab,u_bc,u_ca,u_avg,i_a,i_b,i_c,i_avg,i_d,p_a,p_b,p_c,p_t,q_a,q_b,q_c,q_t,s_a,s_b,s_c,s_t,pf_a,pf_b,pf_c,pf,f,imp_a,imp_r,exp_a,exp_r,swith_data,relay_data,pt1_,pt2,ct1,real_flag,u_unbl,i_unbl,load_type,p_dema,q_dema,s_dema,ep_total,ep_net,eq_total,eq_net)");
			strSql.Append(" values (");
			strSql.Append("@station_id,@meter_id,@evt_time,@v_a,@v_b,@v_c,@v_avg,@u_ab,@u_bc,@u_ca,@u_avg,@i_a,@i_b,@i_c,@i_avg,@i_d,@p_a,@p_b,@p_c,@p_t,@q_a,@q_b,@q_c,@q_t,@s_a,@s_b,@s_c,@s_t,@pf_a,@pf_b,@pf_c,@pf,@f,@imp_a,@imp_r,@exp_a,@exp_r,@swith_data,@relay_data,@pt1_,@pt2,@ct1,@real_flag,@u_unbl,@i_unbl,@load_type,@p_dema,@q_dema,@s_dema,@ep_total,@ep_net,@eq_total,@eq_net)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@station_id", SqlDbType.VarChar,20),
					new SqlParameter("@meter_id", SqlDbType.VarChar,50),
					new SqlParameter("@evt_time", SqlDbType.DateTime),
					new SqlParameter("@v_a", SqlDbType.Float,8),
					new SqlParameter("@v_b", SqlDbType.Float,8),
					new SqlParameter("@v_c", SqlDbType.Float,8),
					new SqlParameter("@v_avg", SqlDbType.Float,8),
					new SqlParameter("@u_ab", SqlDbType.Float,8),
					new SqlParameter("@u_bc", SqlDbType.Float,8),
					new SqlParameter("@u_ca", SqlDbType.Float,8),
					new SqlParameter("@u_avg", SqlDbType.Float,8),
					new SqlParameter("@i_a", SqlDbType.Float,8),
					new SqlParameter("@i_b", SqlDbType.Float,8),
					new SqlParameter("@i_c", SqlDbType.Float,8),
					new SqlParameter("@i_avg", SqlDbType.Float,8),
					new SqlParameter("@i_d", SqlDbType.Float,8),
					new SqlParameter("@p_a", SqlDbType.Float,8),
					new SqlParameter("@p_b", SqlDbType.Float,8),
					new SqlParameter("@p_c", SqlDbType.Float,8),
					new SqlParameter("@p_t", SqlDbType.Float,8),
					new SqlParameter("@q_a", SqlDbType.Float,8),
					new SqlParameter("@q_b", SqlDbType.Float,8),
					new SqlParameter("@q_c", SqlDbType.Float,8),
					new SqlParameter("@q_t", SqlDbType.Float,8),
					new SqlParameter("@s_a", SqlDbType.Float,8),
					new SqlParameter("@s_b", SqlDbType.Float,8),
					new SqlParameter("@s_c", SqlDbType.Float,8),
					new SqlParameter("@s_t", SqlDbType.Float,8),
					new SqlParameter("@pf_a", SqlDbType.Float,8),
					new SqlParameter("@pf_b", SqlDbType.Float,8),
					new SqlParameter("@pf_c", SqlDbType.Float,8),
					new SqlParameter("@pf", SqlDbType.Float,8),
					new SqlParameter("@f", SqlDbType.Float,8),
					new SqlParameter("@imp_a", SqlDbType.Float,8),
					new SqlParameter("@imp_r", SqlDbType.Float,8),
					new SqlParameter("@exp_a", SqlDbType.Float,8),
					new SqlParameter("@exp_r", SqlDbType.Float,8),
					new SqlParameter("@swith_data", SqlDbType.Int,4),
					new SqlParameter("@relay_data", SqlDbType.Int,4),
					new SqlParameter("@pt1_", SqlDbType.Float,8),
					new SqlParameter("@pt2", SqlDbType.Float,8),
					new SqlParameter("@ct1", SqlDbType.Float,8),
					new SqlParameter("@real_flag", SqlDbType.Int,4),
					new SqlParameter("@u_unbl", SqlDbType.Float,8),
					new SqlParameter("@i_unbl", SqlDbType.Float,8),
					new SqlParameter("@load_type", SqlDbType.Float,8),
					new SqlParameter("@p_dema", SqlDbType.Float,8),
					new SqlParameter("@q_dema", SqlDbType.Float,8),
					new SqlParameter("@s_dema", SqlDbType.Float,8),
					new SqlParameter("@ep_total", SqlDbType.Float,8),
					new SqlParameter("@ep_net", SqlDbType.Float,8),
					new SqlParameter("@eq_total", SqlDbType.Float,8),
					new SqlParameter("@eq_net", SqlDbType.Float,8)};
			parameters[0].Value = model.station_id;
			parameters[1].Value = model.meter_id;
			parameters[2].Value = model.evt_time;
			parameters[3].Value = model.v_a;
			parameters[4].Value = model.v_b;
			parameters[5].Value = model.v_c;
			parameters[6].Value = model.v_avg;
			parameters[7].Value = model.u_ab;
			parameters[8].Value = model.u_bc;
			parameters[9].Value = model.u_ca;
			parameters[10].Value = model.u_avg;
			parameters[11].Value = model.i_a;
			parameters[12].Value = model.i_b;
			parameters[13].Value = model.i_c;
			parameters[14].Value = model.i_avg;
			parameters[15].Value = model.i_d;
			parameters[16].Value = model.p_a;
			parameters[17].Value = model.p_b;
			parameters[18].Value = model.p_c;
			parameters[19].Value = model.p_t;
			parameters[20].Value = model.q_a;
			parameters[21].Value = model.q_b;
			parameters[22].Value = model.q_c;
			parameters[23].Value = model.q_t;
			parameters[24].Value = model.s_a;
			parameters[25].Value = model.s_b;
			parameters[26].Value = model.s_c;
			parameters[27].Value = model.s_t;
			parameters[28].Value = model.pf_a;
			parameters[29].Value = model.pf_b;
			parameters[30].Value = model.pf_c;
			parameters[31].Value = model.pf;
			parameters[32].Value = model.f;
			parameters[33].Value = model.imp_a;
			parameters[34].Value = model.imp_r;
			parameters[35].Value = model.exp_a;
			parameters[36].Value = model.exp_r;
			parameters[37].Value = model.swith_data;
			parameters[38].Value = model.relay_data;
			parameters[39].Value = model.pt1_;
			parameters[40].Value = model.pt2;
			parameters[41].Value = model.ct1;
			parameters[42].Value = model.real_flag;
			parameters[43].Value = model.u_unbl;
			parameters[44].Value = model.i_unbl;
			parameters[45].Value = model.load_type;
			parameters[46].Value = model.p_dema;
			parameters[47].Value = model.q_dema;
			parameters[48].Value = model.s_dema;
			parameters[49].Value = model.ep_total;
			parameters[50].Value = model.ep_net;
			parameters[51].Value = model.eq_total;
			parameters[52].Value = model.eq_net;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Power.Model.Meter_h_data model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update meter_h_data set ");
			strSql.Append("station_id=@station_id,");
			strSql.Append("meter_id=@meter_id,");
			strSql.Append("evt_time=@evt_time,");
			strSql.Append("v_a=@v_a,");
			strSql.Append("v_b=@v_b,");
			strSql.Append("v_c=@v_c,");
			strSql.Append("v_avg=@v_avg,");
			strSql.Append("u_ab=@u_ab,");
			strSql.Append("u_bc=@u_bc,");
			strSql.Append("u_ca=@u_ca,");
			strSql.Append("u_avg=@u_avg,");
			strSql.Append("i_a=@i_a,");
			strSql.Append("i_b=@i_b,");
			strSql.Append("i_c=@i_c,");
			strSql.Append("i_avg=@i_avg,");
			strSql.Append("i_d=@i_d,");
			strSql.Append("p_a=@p_a,");
			strSql.Append("p_b=@p_b,");
			strSql.Append("p_c=@p_c,");
			strSql.Append("p_t=@p_t,");
			strSql.Append("q_a=@q_a,");
			strSql.Append("q_b=@q_b,");
			strSql.Append("q_c=@q_c,");
			strSql.Append("q_t=@q_t,");
			strSql.Append("s_a=@s_a,");
			strSql.Append("s_b=@s_b,");
			strSql.Append("s_c=@s_c,");
			strSql.Append("s_t=@s_t,");
			strSql.Append("pf_a=@pf_a,");
			strSql.Append("pf_b=@pf_b,");
			strSql.Append("pf_c=@pf_c,");
			strSql.Append("pf=@pf,");
			strSql.Append("f=@f,");
			strSql.Append("imp_a=@imp_a,");
			strSql.Append("imp_r=@imp_r,");
			strSql.Append("exp_a=@exp_a,");
			strSql.Append("exp_r=@exp_r,");
			strSql.Append("swith_data=@swith_data,");
			strSql.Append("relay_data=@relay_data,");
			strSql.Append("pt1_=@pt1_,");
			strSql.Append("pt2=@pt2,");
			strSql.Append("ct1=@ct1,");
			strSql.Append("real_flag=@real_flag,");
			strSql.Append("u_unbl=@u_unbl,");
			strSql.Append("i_unbl=@i_unbl,");
			strSql.Append("load_type=@load_type,");
			strSql.Append("p_dema=@p_dema,");
			strSql.Append("q_dema=@q_dema,");
			strSql.Append("s_dema=@s_dema,");
			strSql.Append("ep_total=@ep_total,");
			strSql.Append("ep_net=@ep_net,");
			strSql.Append("eq_total=@eq_total,");
			strSql.Append("eq_net=@eq_net");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@station_id", SqlDbType.VarChar,20),
					new SqlParameter("@meter_id", SqlDbType.VarChar,50),
					new SqlParameter("@evt_time", SqlDbType.DateTime),
					new SqlParameter("@v_a", SqlDbType.Float,8),
					new SqlParameter("@v_b", SqlDbType.Float,8),
					new SqlParameter("@v_c", SqlDbType.Float,8),
					new SqlParameter("@v_avg", SqlDbType.Float,8),
					new SqlParameter("@u_ab", SqlDbType.Float,8),
					new SqlParameter("@u_bc", SqlDbType.Float,8),
					new SqlParameter("@u_ca", SqlDbType.Float,8),
					new SqlParameter("@u_avg", SqlDbType.Float,8),
					new SqlParameter("@i_a", SqlDbType.Float,8),
					new SqlParameter("@i_b", SqlDbType.Float,8),
					new SqlParameter("@i_c", SqlDbType.Float,8),
					new SqlParameter("@i_avg", SqlDbType.Float,8),
					new SqlParameter("@i_d", SqlDbType.Float,8),
					new SqlParameter("@p_a", SqlDbType.Float,8),
					new SqlParameter("@p_b", SqlDbType.Float,8),
					new SqlParameter("@p_c", SqlDbType.Float,8),
					new SqlParameter("@p_t", SqlDbType.Float,8),
					new SqlParameter("@q_a", SqlDbType.Float,8),
					new SqlParameter("@q_b", SqlDbType.Float,8),
					new SqlParameter("@q_c", SqlDbType.Float,8),
					new SqlParameter("@q_t", SqlDbType.Float,8),
					new SqlParameter("@s_a", SqlDbType.Float,8),
					new SqlParameter("@s_b", SqlDbType.Float,8),
					new SqlParameter("@s_c", SqlDbType.Float,8),
					new SqlParameter("@s_t", SqlDbType.Float,8),
					new SqlParameter("@pf_a", SqlDbType.Float,8),
					new SqlParameter("@pf_b", SqlDbType.Float,8),
					new SqlParameter("@pf_c", SqlDbType.Float,8),
					new SqlParameter("@pf", SqlDbType.Float,8),
					new SqlParameter("@f", SqlDbType.Float,8),
					new SqlParameter("@imp_a", SqlDbType.Float,8),
					new SqlParameter("@imp_r", SqlDbType.Float,8),
					new SqlParameter("@exp_a", SqlDbType.Float,8),
					new SqlParameter("@exp_r", SqlDbType.Float,8),
					new SqlParameter("@swith_data", SqlDbType.Int,4),
					new SqlParameter("@relay_data", SqlDbType.Int,4),
					new SqlParameter("@pt1_", SqlDbType.Float,8),
					new SqlParameter("@pt2", SqlDbType.Float,8),
					new SqlParameter("@ct1", SqlDbType.Float,8),
					new SqlParameter("@real_flag", SqlDbType.Int,4),
					new SqlParameter("@u_unbl", SqlDbType.Float,8),
					new SqlParameter("@i_unbl", SqlDbType.Float,8),
					new SqlParameter("@load_type", SqlDbType.Float,8),
					new SqlParameter("@p_dema", SqlDbType.Float,8),
					new SqlParameter("@q_dema", SqlDbType.Float,8),
					new SqlParameter("@s_dema", SqlDbType.Float,8),
					new SqlParameter("@ep_total", SqlDbType.Float,8),
					new SqlParameter("@ep_net", SqlDbType.Float,8),
					new SqlParameter("@eq_total", SqlDbType.Float,8),
					new SqlParameter("@eq_net", SqlDbType.Float,8),
					new SqlParameter("@id", SqlDbType.Int,4)};
			parameters[0].Value = model.station_id;
			parameters[1].Value = model.meter_id;
			parameters[2].Value = model.evt_time;
			parameters[3].Value = model.v_a;
			parameters[4].Value = model.v_b;
			parameters[5].Value = model.v_c;
			parameters[6].Value = model.v_avg;
			parameters[7].Value = model.u_ab;
			parameters[8].Value = model.u_bc;
			parameters[9].Value = model.u_ca;
			parameters[10].Value = model.u_avg;
			parameters[11].Value = model.i_a;
			parameters[12].Value = model.i_b;
			parameters[13].Value = model.i_c;
			parameters[14].Value = model.i_avg;
			parameters[15].Value = model.i_d;
			parameters[16].Value = model.p_a;
			parameters[17].Value = model.p_b;
			parameters[18].Value = model.p_c;
			parameters[19].Value = model.p_t;
			parameters[20].Value = model.q_a;
			parameters[21].Value = model.q_b;
			parameters[22].Value = model.q_c;
			parameters[23].Value = model.q_t;
			parameters[24].Value = model.s_a;
			parameters[25].Value = model.s_b;
			parameters[26].Value = model.s_c;
			parameters[27].Value = model.s_t;
			parameters[28].Value = model.pf_a;
			parameters[29].Value = model.pf_b;
			parameters[30].Value = model.pf_c;
			parameters[31].Value = model.pf;
			parameters[32].Value = model.f;
			parameters[33].Value = model.imp_a;
			parameters[34].Value = model.imp_r;
			parameters[35].Value = model.exp_a;
			parameters[36].Value = model.exp_r;
			parameters[37].Value = model.swith_data;
			parameters[38].Value = model.relay_data;
			parameters[39].Value = model.pt1_;
			parameters[40].Value = model.pt2;
			parameters[41].Value = model.ct1;
			parameters[42].Value = model.real_flag;
			parameters[43].Value = model.u_unbl;
			parameters[44].Value = model.i_unbl;
			parameters[45].Value = model.load_type;
			parameters[46].Value = model.p_dema;
			parameters[47].Value = model.q_dema;
			parameters[48].Value = model.s_dema;
			parameters[49].Value = model.ep_total;
			parameters[50].Value = model.ep_net;
			parameters[51].Value = model.eq_total;
			parameters[52].Value = model.eq_net;
			parameters[53].Value = model.id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from meter_h_data ");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
			};
			parameters[0].Value = id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string idlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from meter_h_data ");
			strSql.Append(" where id in ("+idlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Power.Model.Meter_h_data GetModel(int id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 id,station_id,meter_id,evt_time,v_a,v_b,v_c,v_avg,u_ab,u_bc,u_ca,u_avg,i_a,i_b,i_c,i_avg,i_d,p_a,p_b,p_c,p_t,q_a,q_b,q_c,q_t,s_a,s_b,s_c,s_t,pf_a,pf_b,pf_c,pf,f,imp_a,imp_r,exp_a,exp_r,swith_data,relay_data,pt1_,pt2,ct1,real_flag,u_unbl,i_unbl,load_type,p_dema,q_dema,s_dema,ep_total,ep_net,eq_total,eq_net from meter_h_data ");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
			};
			parameters[0].Value = id;

			Power.Model.Meter_h_data model=new Power.Model.Meter_h_data();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Power.Model.Meter_h_data DataRowToModel(DataRow row)
		{
			Power.Model.Meter_h_data model=new Power.Model.Meter_h_data();
			if (row != null)
			{
				if(row["id"]!=null && row["id"].ToString()!="")
				{
					model.id=int.Parse(row["id"].ToString());
				}
				if(row["station_id"]!=null)
				{
					model.station_id=row["station_id"].ToString();
				}
				if(row["meter_id"]!=null)
				{
					model.meter_id=row["meter_id"].ToString();
				}
				if(row["evt_time"]!=null && row["evt_time"].ToString()!="")
				{
					model.evt_time=DateTime.Parse(row["evt_time"].ToString());
				}
				if(row["v_a"]!=null && row["v_a"].ToString()!="")
				{
					model.v_a=decimal.Parse(row["v_a"].ToString());
				}
				if(row["v_b"]!=null && row["v_b"].ToString()!="")
				{
					model.v_b=decimal.Parse(row["v_b"].ToString());
				}
				if(row["v_c"]!=null && row["v_c"].ToString()!="")
				{
					model.v_c=decimal.Parse(row["v_c"].ToString());
				}
				if(row["v_avg"]!=null && row["v_avg"].ToString()!="")
				{
					model.v_avg=decimal.Parse(row["v_avg"].ToString());
				}
				if(row["u_ab"]!=null && row["u_ab"].ToString()!="")
				{
					model.u_ab=decimal.Parse(row["u_ab"].ToString());
				}
				if(row["u_bc"]!=null && row["u_bc"].ToString()!="")
				{
					model.u_bc=decimal.Parse(row["u_bc"].ToString());
				}
				if(row["u_ca"]!=null && row["u_ca"].ToString()!="")
				{
					model.u_ca=decimal.Parse(row["u_ca"].ToString());
				}
				if(row["u_avg"]!=null && row["u_avg"].ToString()!="")
				{
					model.u_avg=decimal.Parse(row["u_avg"].ToString());
				}
				if(row["i_a"]!=null && row["i_a"].ToString()!="")
				{
					model.i_a=decimal.Parse(row["i_a"].ToString());
				}
				if(row["i_b"]!=null && row["i_b"].ToString()!="")
				{
					model.i_b=decimal.Parse(row["i_b"].ToString());
				}
				if(row["i_c"]!=null && row["i_c"].ToString()!="")
				{
					model.i_c=decimal.Parse(row["i_c"].ToString());
				}
				if(row["i_avg"]!=null && row["i_avg"].ToString()!="")
				{
					model.i_avg=decimal.Parse(row["i_avg"].ToString());
				}
				if(row["i_d"]!=null && row["i_d"].ToString()!="")
				{
					model.i_d=decimal.Parse(row["i_d"].ToString());
				}
				if(row["p_a"]!=null && row["p_a"].ToString()!="")
				{
					model.p_a=decimal.Parse(row["p_a"].ToString());
				}
				if(row["p_b"]!=null && row["p_b"].ToString()!="")
				{
					model.p_b=decimal.Parse(row["p_b"].ToString());
				}
				if(row["p_c"]!=null && row["p_c"].ToString()!="")
				{
					model.p_c=decimal.Parse(row["p_c"].ToString());
				}
				if(row["p_t"]!=null && row["p_t"].ToString()!="")
				{
					model.p_t=decimal.Parse(row["p_t"].ToString());
				}
				if(row["q_a"]!=null && row["q_a"].ToString()!="")
				{
					model.q_a=decimal.Parse(row["q_a"].ToString());
				}
				if(row["q_b"]!=null && row["q_b"].ToString()!="")
				{
					model.q_b=decimal.Parse(row["q_b"].ToString());
				}
				if(row["q_c"]!=null && row["q_c"].ToString()!="")
				{
					model.q_c=decimal.Parse(row["q_c"].ToString());
				}
				if(row["q_t"]!=null && row["q_t"].ToString()!="")
				{
					model.q_t=decimal.Parse(row["q_t"].ToString());
				}
				if(row["s_a"]!=null && row["s_a"].ToString()!="")
				{
					model.s_a=decimal.Parse(row["s_a"].ToString());
				}
				if(row["s_b"]!=null && row["s_b"].ToString()!="")
				{
					model.s_b=decimal.Parse(row["s_b"].ToString());
				}
				if(row["s_c"]!=null && row["s_c"].ToString()!="")
				{
					model.s_c=decimal.Parse(row["s_c"].ToString());
				}
				if(row["s_t"]!=null && row["s_t"].ToString()!="")
				{
					model.s_t=decimal.Parse(row["s_t"].ToString());
				}
				if(row["pf_a"]!=null && row["pf_a"].ToString()!="")
				{
					model.pf_a=decimal.Parse(row["pf_a"].ToString());
				}
				if(row["pf_b"]!=null && row["pf_b"].ToString()!="")
				{
					model.pf_b=decimal.Parse(row["pf_b"].ToString());
				}
				if(row["pf_c"]!=null && row["pf_c"].ToString()!="")
				{
					model.pf_c=decimal.Parse(row["pf_c"].ToString());
				}
				if(row["pf"]!=null && row["pf"].ToString()!="")
				{
					model.pf=decimal.Parse(row["pf"].ToString());
				}
				if(row["f"]!=null && row["f"].ToString()!="")
				{
					model.f=decimal.Parse(row["f"].ToString());
				}
				if(row["imp_a"]!=null && row["imp_a"].ToString()!="")
				{
					model.imp_a=decimal.Parse(row["imp_a"].ToString());
				}
				if(row["imp_r"]!=null && row["imp_r"].ToString()!="")
				{
					model.imp_r=decimal.Parse(row["imp_r"].ToString());
				}
				if(row["exp_a"]!=null && row["exp_a"].ToString()!="")
				{
					model.exp_a=decimal.Parse(row["exp_a"].ToString());
				}
				if(row["exp_r"]!=null && row["exp_r"].ToString()!="")
				{
					model.exp_r=decimal.Parse(row["exp_r"].ToString());
				}
				if(row["swith_data"]!=null && row["swith_data"].ToString()!="")
				{
					model.swith_data=int.Parse(row["swith_data"].ToString());
				}
				if(row["relay_data"]!=null && row["relay_data"].ToString()!="")
				{
					model.relay_data=int.Parse(row["relay_data"].ToString());
				}
				if(row["pt1_"]!=null && row["pt1_"].ToString()!="")
				{
					model.pt1_=decimal.Parse(row["pt1_"].ToString());
				}
				if(row["pt2"]!=null && row["pt2"].ToString()!="")
				{
					model.pt2=decimal.Parse(row["pt2"].ToString());
				}
				if(row["ct1"]!=null && row["ct1"].ToString()!="")
				{
					model.ct1=decimal.Parse(row["ct1"].ToString());
				}
				if(row["real_flag"]!=null && row["real_flag"].ToString()!="")
				{
					model.real_flag=int.Parse(row["real_flag"].ToString());
				}
				if(row["u_unbl"]!=null && row["u_unbl"].ToString()!="")
				{
					model.u_unbl=decimal.Parse(row["u_unbl"].ToString());
				}
				if(row["i_unbl"]!=null && row["i_unbl"].ToString()!="")
				{
					model.i_unbl=decimal.Parse(row["i_unbl"].ToString());
				}
				if(row["load_type"]!=null && row["load_type"].ToString()!="")
				{
					model.load_type=decimal.Parse(row["load_type"].ToString());
				}
				if(row["p_dema"]!=null && row["p_dema"].ToString()!="")
				{
					model.p_dema=decimal.Parse(row["p_dema"].ToString());
				}
				if(row["q_dema"]!=null && row["q_dema"].ToString()!="")
				{
					model.q_dema=decimal.Parse(row["q_dema"].ToString());
				}
				if(row["s_dema"]!=null && row["s_dema"].ToString()!="")
				{
					model.s_dema=decimal.Parse(row["s_dema"].ToString());
				}
				if(row["ep_total"]!=null && row["ep_total"].ToString()!="")
				{
					model.ep_total=decimal.Parse(row["ep_total"].ToString());
				}
				if(row["ep_net"]!=null && row["ep_net"].ToString()!="")
				{
					model.ep_net=decimal.Parse(row["ep_net"].ToString());
				}
				if(row["eq_total"]!=null && row["eq_total"].ToString()!="")
				{
					model.eq_total=decimal.Parse(row["eq_total"].ToString());
				}
				if(row["eq_net"]!=null && row["eq_net"].ToString()!="")
				{
					model.eq_net=decimal.Parse(row["eq_net"].ToString());
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select id,station_id,meter_id,evt_time,v_a,v_b,v_c,v_avg,u_ab,u_bc,u_ca,u_avg,i_a,i_b,i_c,i_avg,i_d,p_a,p_b,p_c,p_t,q_a,q_b,q_c,q_t,s_a,s_b,s_c,s_t,pf_a,pf_b,pf_c,pf,f,imp_a,imp_r,exp_a,exp_r,swith_data,relay_data,pt1_,pt2,ct1,real_flag,u_unbl,i_unbl,load_type,p_dema,q_dema,s_dema,ep_total,ep_net,eq_total,eq_net ");
			strSql.Append(" FROM meter_h_data ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" id,station_id,meter_id,evt_time,v_a,v_b,v_c,v_avg,u_ab,u_bc,u_ca,u_avg,i_a,i_b,i_c,i_avg,i_d,p_a,p_b,p_c,p_t,q_a,q_b,q_c,q_t,s_a,s_b,s_c,s_t,pf_a,pf_b,pf_c,pf,f,imp_a,imp_r,exp_a,exp_r,swith_data,relay_data,pt1_,pt2,ct1,real_flag,u_unbl,i_unbl,load_type,p_dema,q_dema,s_dema,ep_total,ep_net,eq_total,eq_net ");
			strSql.Append(" FROM meter_h_data ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM meter_h_data ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.id desc");
			}
			strSql.Append(")AS Row, T.*  from meter_h_data T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "meter_h_data";
			parameters[1].Value = "id";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

